package com.gps.funnymath.domains;

import java.util.Random;

import com.gps.funnymath.concreteItems.ConcreteNumber;


public class NumberDomain implements Domain{

	static Random random = new Random();
	
	private int minNumber;
	private int maxNumber;
	
	public NumberDomain(int minNumber, int maxNumber){
		
		if(minNumber>maxNumber){
			this.minNumber = 0;
			this.maxNumber = 0;
		}
		
		this.minNumber = minNumber;
		this.maxNumber = maxNumber;
	}
	
	public ConcreteNumber getRandom(){
		int randomNumberInDomain = random.nextInt(maxNumber) + minNumber;
		return new ConcreteNumber(randomNumberInDomain);		
	}

	@Override
	public boolean contains(Object object) {

		if(object instanceof Integer){
			Integer number = (int)object;
			if(number>=minNumber && number<=maxNumber)
				return true;
		}
		
		return false;
	}

}
